package com.zhijiang.hospital.service.impl;

class MyWorld {
    public static void main(String[] args) {
        System.out.println("Welcome to my world!");
        System.out.println("This is my world that I've been dreaming of...");

        Room bedroom = new Room("Bedroom", "It's a cozy bedroom with a queen-sized bed in the corner and a large window.");
        Room livingRoom = new Room("Living Room", "It's a spacious living room with a big TV and a comfortable sofa.");
        Room kitchen = new Room("Kitchen", "It's a modern kitchen with all the necessary appliances.");
        Room office = new Room("Office", "It's a neat office with a nice desk, a computer and a printer.");

        bedroom.connectTo(livingRoom);
        livingRoom.connectTo(kitchen);
        kitchen.connectTo(office);

        Player player = new Player("Bob", bedroom);
        player.walk();
        player.walk();
        player.walk();
        player.walk();
        player.lookAround();
    }
}

class Room {
    String name;
    String description;
    Room north;
    Room east;
    Room south;
    Room west;

    public Room(String name, String description) {
        this.name = name;
        this.description = description;
    }

    public void connectTo(Room room) {
        if (north == null) {
            north = room;
            room.south = this;
        } else if (east == null) {
            east = room;
            room.west = this;
        } else if (south == null) {
            south = room;
            room.north = this;
        } else if (west == null) {
            west = room;
            room.east = this;
        }
    }

    public void describe() {
        System.out.println(name);
        System.out.println(description);
    }
}

class Player {
    String name;
    Room currentRoom;

    public Player(String name, Room currentRoom) {
        this.name = name;
        this.currentRoom = currentRoom;
    }

    public void walk() {
        System.out.println("Walking...");
        if (currentRoom.north != null) {
            currentRoom = currentRoom.north;
        } else if (currentRoom.east != null) {
            currentRoom = currentRoom.east;
        } else if (currentRoom.south != null) {
            currentRoom = currentRoom.south;
        } else if (currentRoom.west != null) {
            currentRoom = currentRoom.west;
        }
    }

    public void lookAround() {
        System.out.println("Looking around...");
        currentRoom.describe();
    }
}